<!--<!--批量-->
<?php
$name = $age = $email = $url = '';
$ageErr =$emailErr= $urlErr = '';
if($_SERVER['REQUEST_METHOD'] =='POST'){
$filters = array(
    'name' => array(
        'filter' =>FILTER_SANITIZE_STRING
    ),
    'age' => array(
        'filter' => FILTER_VALIDATE_INT,
        'options' => array(
            'min_range' => 1,
            'max_range' => 120
        )
    ),
    'email' => array(
        'filter' => FILTER_VALIDATE_EMAIL
    )
);
$result = filter_input_array(INPUT_POST,$filters);
if(!$result['age']){
    echo '年龄必须在1-120<br>';
}else if(!$result['email']){
    echo 'email 不合法';
}else if(!$result['name']){
    echo '姓名不对';
}else{
    echo 'ok';
}}
?>


<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF'])?>" method="post">
    <label for="name">姓名</label>
    <input type="text" name="fname" id="name" value="<?php echo $name;?>"><br>
    <label for="age">年龄</label>
    <input type="text" name="age" id="age" value="<?php echo $age ;?>">
    <span><?php echo $ageErr;?></span>
    <br>
    <label for="email">邮箱</label>
    <input type="text" name="email" value="<?php echo $email; ?>">
    <span><?php echo $emailErr;?></span>
    <br>
    <label for="url">url净化</label>
    <input type="text" id="url" name="url" value="<?php echo $url;?>">
    <span><?php echo $urlErr;?></span>

    <br><br>
    <input type="submit" value="提交">
</form>
